package com.aoxon.cargo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.aoxon.cargo.R;
import com.aoxon.cargo.bean.Supplier;
import com.aoxon.cargo.shared.SupIndexShared;
import com.aoxon.cargo.util.DataUtil;

public class SupRegisterSuccessActivity extends BaseActivity {
	Supplier supplier;
	ImageView ivReturn;
	TextView tvTitle;
	TextView tvCargoNum;
	TextView tvPhone;
	TextView tvUpdatePassword;
	TextView tvFillInfo;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setup();
	}
	
	private void setup(){
		supplier = DataUtil.gson.fromJson(
		getIntent().getStringExtra("supplier"),Supplier.class);
		SupIndexShared.saveSupplier(getIntent().getStringExtra("supplier"));
		
		setContentView(R.layout.sup_register_success);
		ivReturn = (ImageView) findViewById(R.id.ivPublicTitleReturn);
		tvTitle = (TextView) findViewById(R.id.tvPublicTiTle);
		tvCargoNum = (TextView) findViewById(R.id.tvCargoNum_register_success);
		tvPhone = (TextView) findViewById(R.id.tvPhoneNum_register_success);
		tvFillInfo = (TextView) findViewById(R.id.tvFillInfo_register_success);
		tvUpdatePassword = (TextView) findViewById(R.id.tvUpdatePassword_register_success);
		
		ivReturn.setOnClickListener(onClick);
		tvFillInfo.setOnClickListener(onClick);
		
		tvTitle.setText("供应商注册");
		tvCargoNum.setText(supplier.getSupCount());
		tvPhone.setText(supplier.getSupPhone());
		ivReturn.setOnClickListener(onClick);
		tvUpdatePassword.setOnClickListener(onClick);
	}
	
	OnClickListener onClick = new OnClickListener(){

		@Override
		public void onClick(View view) {
			// TODO Auto-generated method stub
			switch(view.getId()){
			case R.id.ivPublicTitleReturn:
				//不用getBaseContext,依旧OK
				Intent intent = new Intent(SupRegisterSuccessActivity.this,
						PurMoreActivity.class);
				startActivity(intent);
				SupRegisterSuccessActivity.this.finish();
				break;
			case R.id.tvUpdatePassword_register_success:
				Intent intentRevamp = new Intent(SupRegisterSuccessActivity.this,
						SupRevampPasswordActivity.class);
				startActivity(intentRevamp);
				break;
			case R.id.tvFillInfo_register_success:
				Intent intentFill = new Intent(SupRegisterSuccessActivity.this,
						SupFillInfo1Activity.class);
				startActivity(intentFill);
				break;
			}
		}
		
	};
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
			Intent intent = new Intent(SupRegisterSuccessActivity.this,
					PurMoreActivity.class);
			;
			startActivity(intent);
			this.finish();
			return false;
		}
		return false;
	}
	
}
